package com.situ.web.controller;

import com.situ.web.service.IBanjiService;
import com.situ.web.service.impl.BanjiServiceImpl;
import com.situ.web.util.JSONResult;
import com.situ.web.util.JSONUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

//@WebServlet("/echarts")
@WebServlet(value = {"/echarts"})
public class EChartsServlet extends HttpServlet {
    private IBanjiService banjiService = new BanjiServiceImpl();

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String method = req.getParameter("method");
        switch (method) {
            case "selectBanjiCount":
                selectBanjiCount(req, resp);
                break;
        }
    }

    private void selectBanjiCount(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        System.out.println("EChartsServlet.selectBanjiCount");
        JSONResult jsonResult = banjiService.selectBanjiCount();
        JSONUtil.obj2Json(jsonResult, resp);
    }
}
